package com.example.a22310.myapplication.ViewModel.Attention;


import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Toast;

import com.example.a22310.myapplication.Beans.user;
import com.example.a22310.myapplication.Listener.ActivityLisenter;
import com.example.a22310.myapplication.Model.AttentionModel;

public class AddAttentionViewModel implements ActivityLisenter<user> {
    private ActivityMasterDetailBinding binding;
    private AppCompatActivity activity;
    private int userid,attentionid,flag;
    private String name,pic;


    public AddAttentionViewModel(AppCompatActivity activity, ActivityMasterDetailBinding binding,
                                 int userid,int attentionid,String name,String pic,int flag){
        this.activity = activity;
        this.binding = binding;
        this.userid = userid;
        this.attentionid = attentionid;
        this.name = name;
        this.pic=pic;
        this.flag=flag;
        binding.setAttentions(this);
    }

    public void attention(View view){
        AttentionModel attentionModel=new AttentionModel();
        attentionModel.addAttention(AddAttentionViewModel.this,userid,attentionid,name,pic,flag);
    }


    @Override
    public void onSuccess(user user) {
        if (user.getSuccess() ==1 ){
            Toast.makeText(activity,"关注成功",Toast.LENGTH_LONG).show();
        }else{
            Toast.makeText(activity,"关注失败",Toast.LENGTH_LONG).show();
        }


    }

    @Override
    public void onFailure() {
        Toast.makeText(activity,"服务器超时",Toast.LENGTH_LONG).show();
    }
}
